﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Security;
using System.Web;
using IHISCETeim.Library;
using IHISCETeim.Model;
using IHISCETeim.DAL;
using System.Data;
using System.Threading;

namespace IHISCETeim.BLL
{
    public class ReMachineTestController : BaseController
    {
        private static List<ReMachineTestTempleteInfo> ReMachineTestTemplete_GetAll()
        {
            List<ReMachineTestTempleteInfo> _all = null;
            try
            {
                _all = DC.Get<List<ReMachineTestTempleteInfo>>(BaseController.AllReMachineTestTemplete);
                if (_all == null)
                {

                    _all = CBO.FillCollection<ReMachineTestTempleteInfo>(ReMachineTestDAL.ReMachineTestTemplete_GetAll());
                    DC.Add(BaseController.AllReMachineTestTemplete, _all);
                }

                return _all;
            }
            catch
            {
                return new List<ReMachineTestTempleteInfo>();
            }
        }

        /// <summary>
        /// 根据父级ID获取明细
        /// </summary>
        /// <param name="parId"></param>
        /// <returns></returns>
        public static List<ReMachineTestTempleteInfo> GetTempleteByParTmpId(int parId)
        {
            List<ReMachineTestTempleteInfo> _all = ReMachineTestTemplete_GetAll();
            return _all.FindAll(e => e.ParId == parId);
        }


        public static int Add(ReMachineTestInfo obj, List<ReMachineTestDetailInfo> objDetail)
        {
            return ReMachineTestDAL.Add(obj, objDetail);
        }

        public static bool Delete(int TestID)
        {
            return ReMachineTestDAL.Delete(TestID);
        }
        public static List<ReMachineTestDetailInfo> GetDetailByTestID(int TestID)
        {
            return CBO.FillCollection<ReMachineTestDetailInfo>( ReMachineTestDAL.GetDetailByTestID(TestID));
        }
        public static ReMachineTestInfo GetList(int TestID)
        {
            return CBO.FillObject<ReMachineTestInfo>( ReMachineTestDAL.GetList(TestID));
        }
        public static DataTable GetPagination(string whereSql, int PageIndex, int PageSize, string Sort, ref int TotalCount)
        {
            return ReMachineTestDAL.GetPagination(whereSql, PageIndex, PageSize, Sort, ref TotalCount);
        }
        public static bool Update(ReMachineTestInfo obj, List<ReMachineTestDetailInfo> objDetail)
        {
            return ReMachineTestDAL.Update(obj, objDetail);
        }
    }
}
